package com.mathassistant.client.view;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.mathassistant.client.presenter.FooterPresenter.Display;

public class FooterView extends Composite implements Display{

	private static FooterViewUiBinder uiBinder = GWT
			.create(FooterViewUiBinder.class);
	@UiField Anchor anchorLogout;
	@UiField Anchor anchorLogin;
	@UiField Anchor anchorAbout;
	@UiField Label usernameLabel;

	interface FooterViewUiBinder extends UiBinder<Widget, FooterView> {
	}

	public FooterView() {
		initWidget(uiBinder.createAndBindUi(this));
		anchorAbout.addStyleName("footer-anchor");
		anchorLogin.addStyleName("footer-anchor");
		anchorLogout.addStyleName("footer-anchor");
		
	}

	@Override
	public HasClickHandlers getLoginAnchor() {
		// TODO Auto-generated method stub
		return anchorLogin;
	}

	@Override
	public HasClickHandlers getLogoutAnchor() {
		// TODO Auto-generated method stub
		return anchorLogout;
	}

	@Override
	public HasClickHandlers getAboutAnchor() {
		// TODO Auto-generated method stub
		return anchorAbout;
	}
		
	@Override
	public Widget asWidget() {
		return this;
	}

	@Override
	public void setToAdminView(String userName) {
		// TODO Auto-generated method stub
		anchorLogout.setVisible(true);
		anchorLogin.setVisible(false);
		usernameLabel.setText(userName);
	}

	@Override
	public void setToUserView() {
		// TODO Auto-generated method stub
		anchorLogout.setVisible(false);
		anchorLogin.setVisible(true);
		usernameLabel.setText("");
	}
}
